// fitsr - astronomical image viewer
//
// Copyright (C) 2016 Ralph Giles
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General
// Public License along with this program.  If not, see
// <https://www.gnu.org/licenses/>.

extern crate gtk;
extern crate gdk;

use gtk::traits::*;

fn main() {
    if gtk::init().is_err() {
        println!("Error: Failed to initialize GTK!");
        return;
    }

    let window = gtk::Window::new(gtk::WindowType::Toplevel).unwrap();
    window.set_title("fitsr");

    window.connect_delete_event(|_, _| {
        gtk::main_quit();
        gtk::signal::Inhibit(false)
    });

    window.connect_key_press_event(|_, key| {
        if key.keyval == gdk::enums::key::Escape as u32 {
            gtk::main_quit();
        }
        gtk::signal::Inhibit(true)
    });

    let button = gtk::Button::new_with_label("Click me!").unwrap();
    button.connect_clicked(|_| {
        println!("click!");
    });
    window.add(&button);

    window.show_all();
    gtk::main()
}
